﻿

using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace SageKing.OpenIddict.UI.Identity.Api;

/// <summary>
/// 用户登录参数
/// </summary>
public class LoginInput
{

    [Required]
    [EmailAddress]
    public string Email { get; set; } = ""; 

    [Display(Name = "Remember me?")]
    public bool RememberMe { get; set; }

    /// <summary>
    /// 账号、手机号
    /// </summary>
    /// <example>admin</example>
    //[Required(ErrorMessage = "账号、手机号不能为空"), MinLength(5, ErrorMessage = "账号/手机号不能少于5个字符")]
    public string Account { get; set; }

    /// <summary>
    /// 密码
    /// </summary>
    /// <example>123456</example>
    [Required(ErrorMessage = "密码不能为空"), MinLength(6, ErrorMessage = "密码不能少于6个字符")]
    [DataType(DataType.Password)]
    public string Password { get; set; } = "";

    /// <summary>
    /// 验证码Id
    /// </summary>
    public long CodeId { get; set; }

    /// <summary>
    /// 验证码
    /// </summary>
    public string Code { get; set; }
    /// <summary>
    /// 是否验证 验证码 aes加密
    /// 0:默认验证 1:不用验证码
    /// </summary>
    public string CodeType { get; set; } = "1";

    /// <summary>
    /// 加密类型
    /// </summary>
    public CryptogramEnum CryptType { get; set; } = CryptogramEnum.AESErp;
}

public class LoginPhoneInput
{
    /// <summary>
    /// 手机号码
    /// </summary>
    /// <example>admin</example>
    [Required(ErrorMessage = "手机号码不能为空")]
    //[DataValidation(ValidationTypes.PhoneNumber, ErrorMessage = "手机号码不正确")]
    public string Phone { get; set; }

    /// <summary>
    /// 验证码
    /// </summary>
    /// <example>123456</example>
    [Required(ErrorMessage = "验证码不能为空"), MinLength(4, ErrorMessage = "验证码不能少于4个字符")]
    public string Code { get; set; }
}

public class LoginQRInput
{
    [Required(ErrorMessage = "guid"), MinLength(16, ErrorMessage = "guid不能少于16个字符")]
    public string Guid { get; set; }
}
public class WeiXinQrcodeInput
{
    /// <summary>
    /// 获取或设置二维码有效期（单位：秒）。
    /// </summary>
    public int ExpiresIn { get; set; } = 0;
    /// <summary>
    /// 二维码类型 action_name
    /// QR_SCENE 为临时的整型参数值
    /// QR_LIMIT_SCENE 为永久的整型参数值
    /// QR_STR_SCENE 为临时的字符串参数值
    /// QR_LIMIT_STR_SCENE 为永久的字符串参数值
    /// </summary>
    public WeiXinQrcodeActionType ActionType { get; set; } = WeiXinQrcodeActionType.QR_STR_SCENE;

    /// <summary>
    /// 获取或设置场景值 ID  scene_id
    /// QR_SCENE为临时的整型参数值，
    /// QR_LIMIT_SCENE为永久的整型参数值，
    /// </summary>
    public long? SceneId { get; set; }

    /// <summary>
    /// 获取或设置场景描述 scene_str
    /// QR_STR_SCENE为临时的字符串参数值
    /// QR_LIMIT_STR_SCENE为永久的字符串参数值
    /// </summary>
    public string? SceneString { get; set; }
}
public enum WeiXinQrcodeActionType
{
    /// <summary>
    /// QR_SCENE 为临时的整型参数值
    /// </summary>
    QR_SCENE,
    /// <summary>
    /// QR_LIMIT_SCENE 为永久的整型参数值
    /// </summary>
    QR_LIMIT_SCENE,
    /// <summary>
    /// QR_STR_SCENE 为临时的字符串参数值
    /// </summary>
    QR_STR_SCENE,
    /// <summary>
    /// QR_LIMIT_STR_SCENE 为永久的字符串参数值
    /// </summary>
    QR_LIMIT_STR_SCENE
}

/// <summary>
/// 密码加密枚举
/// </summary>
[Description("密码加密枚举")]
public enum CryptogramEnum
{
    /// <summary>
    /// MD5
    /// </summary>
    [Description("MD5")]
    MD5 = 0,

    /// <summary>
    /// SM2（国密）
    /// </summary>
    [Description("SM2")]
    SM2 = 1,

    /// <summary>
    /// SM4（国密）
    /// </summary>
    [Description("SM4")]
    SM4 = 2,

    /// <summary>
    /// AES js
    /// </summary>
    [Description("AES")]
    AES = 3,
    /// <summary>
    /// AES erp
    /// </summary>
    [Description("AESErp")]
    AESErp = 4,
    /// <summary>
    /// AES AESAI
    /// </summary>
    [Description("AESAI")]
    AESAI = 5
}